home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 August: Tool Chest / Apple_Developer_Group_August_1996_Tool_Chest.iso / Sample Code / Snippets / Processes / Launch Me / Read Me - LaunchMe.doc next >
Encoding:
Text File  |  1996-03-15  |  2.3 KB  |  46 lines  |  [TEXT/CWIE]

  1. /*                                            LaunchMe
  2.  
  3.     This application and code resource will launch an application without a running application
  4.     needing to call LaunchApplication.  This is useful for applications that need to launch
  5.     another application, but due to fact that there isn't enough currently free memory can't.
  6.     
  7.     When you call LaunchApplication() there has to be enough free memory to launch that
  8.     application at the time of the call.  It doesn't matter that LaunchApplication() isn't
  9.     going to launch that application until someone calls GetNextEvent, by which time that
  10.     memory might be free.
  11.     
  12.     This sample is meant to combat that problem.  It shows you how to install a Time Manager
  13.     task which will install a Notification Manager task which will call LaunchApplication on
  14.     an application which was selected while the original application was running.
  15.     
  16.     You cannot call LaunchApplication() from a Time Manager task, but you can from a
  17.     Notification Manager task.  However, you can't install a working Notification Manager
  18.     task and then quit your application because the notification will never get called (which
  19.     is probably a good thing).
  20.     
  21.     The Time Manager doesn't have such a restriction making it the perfect candidate for this
  22.     little hack.
  23.     
  24.     Your application would set up the structure needed to tell the Notification Manager task
  25.     what application to launch, it would then post the Time Manager task and quit.  You can
  26.     adjust the delay time to suite your exit time, it is currently 1 second (1000 milliseconds).
  27.     
  28.     Once your application quits there should be enough memory to launch the new application and
  29.     the user never knows anything strange happened.  If there still isn't enough memory to
  30.     launch the other application there is no (easy) way to tell the user since your application
  31.     has quit and there is no one to post a dialog.  For this reason you should do a preflight
  32.     check to be reasonably certain that the launch will succeed.
  33.     
  34.     The Notification Manager task removes the Time Manager task and itself, so this should
  35.     not leak any precious memory.
  36.     
  37.     This is built as 68K code which considerably simplifies things, and there won't be much
  38.     if any speed decrease over a PowerPC version.
  39.     
  40.     If you have any bug reports or comments on how this could be improved, please let me know
  41.     at mcookson@apple.com.
  42.  
  43.     Mark Cookson
  44.     Developer Technical Support
  45.     Apple Computer, Inc.
  46. */